import {createApp} from 'vue'
import MessageContainer from './MessageContainer.vue'

const container = document.createElement('div')
document.body.appendChild(container)

const app = createApp(MessageContainer)
app.mount(container)

const addMessage = (message: string, type: 'success' | 'warning' | 'info' | 'error') => {
    const instance = app._context.provides.addMessage
    if (instance) {
        instance(message, type)
    } else {
        console.error('addMessage is not provided')
    }
}

export default addMessage
